﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
    <script src="/lib/date/wdatepicker.js"></script>
</head>
<body style="background-color: white;">
    <section class="container-fluid" style="background-color: white;">
        <form class="form-horizontal m15_t" id="form">
            <div class="tab-content">
                <div class="tab-pane fade in active" id="home">
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>公司名称：</label>
                        <div class="wd250 m15_l">
                            <select class="form-control" name="companyId">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>收款银行编码：</label>
                        <div class="wd250 m15_l">
                            <div class="wd250">
                                <select class="form-control" name="bankCode">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>商户单号：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="text" name="clientOrderNo" maxlength="40" autocomplete="off" placeholder="长度必须介于 3 和 40 之间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>收款卡号：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="text" name="depositCardNumber" maxlength="20" autocomplete="off" placeholder="长度必须介于 12 和 20 之间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>订单时间：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control Wdate" type="text" name="depositDate" maxlength="40" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d'})" autocomplete="off" placeholder="长度必须介于 3 和 40 之间">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>订单金额：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="text" name="depositAmount" maxlength="10" autocomplete="off" placeholder="请正确填写付款金额">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label">客户银行：</label>
                        <div class="wd250 m15_l">
                            <div class="wd250">
                                <select class="form-control" name="clientBankName">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label">客户姓名：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="text" name="clientAccountName" maxlength="40" autocomplete="off" placeholder="长度必须介于 2 和 40 之间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label">客户卡号：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="text" name="clientCardNumber" maxlength="20" autocomplete="off" placeholder="长度必须介于 12 和 20 之间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>交易类型：</label>
                        <div class="wd250 m15_l">
                            <div class="wd250">
                                <select class="form-control" name="transtype">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label">客户附言：</label>
                        <div class="wd250 m15_l">
                            <input class="form-control" type="text" name="postScript" maxlength="40" autocomplete="off" placeholder="请正确填写客户银行地区,">
                        </div>
                    </div>
                </div>
            </div>
        </form>

    </section>

    <script type="text/javascript">
        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name] !== undefined) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        };

        var companyId = $("select[name='companyId']");
        var bankCode = $("select[name='bankCode']");
        var clientBankName = $("select[name='clientBankName']");
        var transtype = $("select[name='transtype']");
        var payType = $("select[name='payType']");

        $(function () {

            var cover = FlashPay.UI.Mask({
                obj: $("body"),
                opacity: 0.5
            });

            FlashPay.Util.Ajax({
                type: "POST",
                url: "/DepositMatchRecord/GetDepositMatchRecordAdd",
                data: null,
                success: function (response) {
                    if (response.success) {

                        //AddPermission

                        if (response.data.companyResponse != null) {
                            companyId.empty();
                            companyId.append("<option value=''>请选择</option>");

                            $.each(response.data.companyResponse, function (i, item) {
                                companyId.append("<option value='" + item.companyID + "'>" + item.companyName + "</option >");
                            });
                        }

                        if (response.data.bankInfoResponse != null) {
                            bankCode.empty();
                            bankCode.append("<option value=''>请选择</option>");

                            clientBankName.empty();
                            clientBankName.append("<option value=''>请选择</option>");

                            $.each(response.data.bankInfoResponse, function (i, item) {
                                bankCode.append("<option value='" + item.bankCode + "'>" + item.bankName + "</option >");
                                clientBankName.append("<option value='" + item.bankCode + "'>" + item.bankName + "</option >");
                            });
                        }

                        if (response.data.transtypes != null) {
                            transtype.empty();
                            transtype.append("<option value=''>请选择</option>");

                            $.each(response.data.transtypes, function (i, item) {
                                transtype.append("<option value='" + item.configValue + "'>" + item.configContent + "</option >");
                            });
                        }

                        if (response.data.paytype != null) {
                            payType.empty();
                            payType.append("<option value=''>请选择</option>");

                            $.each(response.data.paytype, function (i, item) {
                                payType.append("<option value='" + item.configValue + "'>" + item.configContent + "</option >");
                            });
                        }

                        cover.Remove();
                    } else {

                    }
                },
                error: function (e) {
                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试");
                }
            });
        })

        function save() {

            var data = $("#form").serializeObject();
            data.clientBankName = $("select[name='clientBankName']").find("option:selected").text();
            data.payType = $("select[name='payType']").find("option:selected").text();

            console.info(data);

            FlashPay.Util.Ajax({
                url: '/DepositMatchRecord/Add',
                type: 'POST',
                data: data,
                success: function (response) {
                    if (response.success) {
                        FlashPay.UI.DialogOpener().Tip_success("操作成功！");
                        FlashPay.UI.DialogOpener().doSearch();
                        FlashPay.UI.CloseDialog();
                    } else {
                        FlashPay.UI.Tip_short_warning("操作失败！" + response.errorMessage);
                    }
                },
                error: function (json) {
                    FlashPay.UI.Tip_short_warning("操作失败！请查看网络，请重试!");
                }
            });
    }

        
    </script>
</body>
</html>